package com.health.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.health.dao.SetMealMapper;
import com.health.pojo.Setmeal;
import com.health.vo.PageResult;

import javax.annotation.Resource;

@Service
public class SetMealServiceImpl implements SetMealService{
    @Resource
    private SetMealMapper setMealMapper;

    @Override
    public PageResult<Setmeal> findPage(Integer pageNow, Integer pageSize, String query) {
        //分页插件
        PageHelper.startPage(pageNow, pageSize);
        //执行查询，Page中包含了查询到的总数，以及分页后的列表
        Page<Setmeal> page = setMealMapper.findByQuery(query);

        //封装查询到的总数与列表
        return new PageResult<>(page.getTotal(), page.getResult());
    }
}
